diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Typers.scala | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 17723218d9..59bcb7efa6 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -1957,7 +1957,9 @@ trait Typers requires Analyzer { if (tpt1.tpe.symbol hasFlag ABSTRACT) error(tree.pos, tpt1.tpe.symbol + " is abstract; cannot be instantiated") - else if (!(tpt1.tpe <:< tpt1.tpe.typeOfThis) && !phase.erasedTypes) + else if (tpt1.tpe.symbol.thisSym != tpt1.tpe.symbol && + !(tpt1.tpe <:< tpt1.tpe.typeOfThis) && + !phase.erasedTypes) error(tree.pos, tpt1.tpe.symbol + " cannot be instantiated because it does not conform to its self-type "+ tpt1.tpe.typeOfThis) |