由于某些中间构造函数调用,没有PerfHelper类型的封闭实例可用 [英] No enclosing instance of type PerfHelper is available due to some intermediate constructor invocation
本文介绍了由于某些中间构造函数调用,没有PerfHelper类型的封闭实例可用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
考虑以下代码:
class abstract Normal1 extends Something
{
}
class Outer
{
class abstract Inner extends Normal1
{
}
}
class General extends Outer.Inner // Problem occurs at this
{
}
发生问题我得到的错误是由于一些中间构造函数调用,没有PerfHelper类型的封闭实例可用。
The error I am getting is "No enclosing instance of type PerfHelper is available due to some intermediate constructor invocation"
我的问题是可以像上面那样扩展内部类吗?
My question is can I extend the inner class like above ?
推荐答案
将内部类声明为 static ,您应该可以对其进行扩展:
Declare the inner class as static and you should be able to extend it:
class outer {
static abstract class inner extends normal1 { }
}
如果inner不是抽象的,则它与外部绑定在一起,并且仅在外部实例存在时才存在。检查这是否是您真正想要的。
If inner is not abstract, it's tied to outer, and can only exist when an instance of outer exists. Check to see if this is what you really want.
这篇关于由于某些中间构造函数调用,没有PerfHelper类型的封闭实例可用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文