diff options
author | odersky <odersky@gmail.com> | 2015-06-22 11:17:38 +0200 |
---|---|---|
committer | odersky <odersky@gmail.com> | 2015-06-22 11:17:38 +0200 |
commit | f03f5b0bea0296564c3f41e4375ead48819254d0 (patch) | |
tree | 5aabe689d9ccc5c583391305a13a806b862574e2 /src | |
parent | 478be16e8d6af6004215682dda4730b78533c543 (diff) | |
parent | 0ec9c927941ab3155d0c5edacfe3a21c8c4b74ca (diff) | |
download | dotty-f03f5b0bea0296564c3f41e4375ead48819254d0.tar.gz dotty-f03f5b0bea0296564c3f41e4375ead48819254d0.tar.bz2 dotty-f03f5b0bea0296564c3f41e4375ead48819254d0.zip |
Merge pull request #668 from lampepfl/fix/#650-self-types
Fix checking whether types are instantiable.
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/typer/Checking.scala | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/typer/Checking.scala b/src/dotty/tools/dotc/typer/Checking.scala index 9047b8cb3..cd06618e6 100644 --- a/src/dotty/tools/dotc/typer/Checking.scala +++ b/src/dotty/tools/dotc/typer/Checking.scala @@ -50,8 +50,11 @@ object Checking { if (cls.is(AbstractOrTrait)) ctx.error(d"$cls is abstract; cannot be instantiated", pos) if (!cls.is(Module)) { - val selfType = tp.givenSelfType.asSeenFrom(tref.prefix, cls.owner) - if (selfType.exists && !(tp <:< selfType)) + // Create a synthetic singleton type instance, and check whether + // it conforms to the self type of the class as seen from that instance. + val stp = SkolemType(tp) + val selfType = tref.givenSelfType.asSeenFrom(stp, cls) + if (selfType.exists && !(stp <:< selfType)) ctx.error(d"$tp does not conform to its self type $selfType; cannot be instantiated") } case _ => |