diff options
author | Martin Odersky <odersky@gmail.com> | 2013-12-14 17:32:16 +0100 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2013-12-14 17:32:16 +0100 |
commit | 01db9a68e5e68f08c8236c23c905009789d51587 (patch) | |
tree | 3e45103b0d36505d6f86f3024e56780e840c156b /src/dotty/tools/dotc/typer | |
parent | d65587ae74cfe2dc7601f57e163b7e22bf89582a (diff) | |
download | dotty-01db9a68e5e68f08c8236c23c905009789d51587.tar.gz dotty-01db9a68e5e68f08c8236c23c905009789d51587.tar.bz2 dotty-01db9a68e5e68f08c8236c23c905009789d51587.zip |
Fixed several deep problems in handling of types and symbols.
1. We forgot to mark declaration symbols Deferred.
2. Types with NoPrefix and the same name got identified. Fixed by adding a new category WithNoPrefix to named types, and changing the way named types get generated.
3. Self types lacked parameters. (Question: Do we need to also track type members?)
4. Printers caused cyclic reference errors. Now some print operations are more careful with forcing.
5. Namedparts accumulator has to be more careful with ThisTypes. Because self types now contain parameters, which might lead back to this, we only add the class name (or the source module, if it's a module class).
6. toBounds in TypeApplications needs to use Co/Contra aliases for expanded name parameters, not just local ones.
Diffstat (limited to 'src/dotty/tools/dotc/typer')
-rw-r--r-- | src/dotty/tools/dotc/typer/Applications.scala | 13 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/ImportInfo.scala | 2 | ||||
-rw-r--r-- | src/dotty/tools/dotc/typer/Namer.scala | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala index 64f44ee5e..dba95c689 100644 --- a/src/dotty/tools/dotc/typer/Applications.scala +++ b/src/dotty/tools/dotc/typer/Applications.scala @@ -621,10 +621,13 @@ trait Applications extends Compatibility { self: Typer => } println(i"case 2 $unapplyArgType ${ctx.typerState.constraint}") unapplyArgType - } else errorType( - i"Pattern type $unapplyArgType is neither a subtype nor a supertype of selector type $wpt", - tree.pos) - + } else { + // println("Neither sub nor super") + // println(TypeComparer.explained(implicit ctx => unapplyArgType <:< wpt)) + errorType( + i"Pattern type $unapplyArgType is neither a subtype nor a supertype of selector type $wpt", + tree.pos) + } var argTypes = unapplyArgs(mt.resultType) val bunchedArgs = argTypes match { case argType :: Nil if argType.isRepeatedParam => untpd.SeqLiteral(args) :: Nil @@ -666,7 +669,7 @@ trait Applications extends Compatibility { self: Typer => isApplicable(methRef, args, resultType) case _ => val app = tp.member(nme.apply) - app.exists && app.hasAltWith(d => isApplicable(TermRef(tp, nme.apply).withDenot(d), args, resultType)) + app.exists && app.hasAltWith(d => isApplicable(TermRef(tp, nme.apply, d), args, resultType)) } /** In a set of overloaded applicable alternatives, is `alt1` at least as good as diff --git a/src/dotty/tools/dotc/typer/ImportInfo.scala b/src/dotty/tools/dotc/typer/ImportInfo.scala index 9942e1915..d72e12baa 100644 --- a/src/dotty/tools/dotc/typer/ImportInfo.scala +++ b/src/dotty/tools/dotc/typer/ImportInfo.scala @@ -86,7 +86,7 @@ class ImportInfo(val sym: Symbol, val selectors: List[untpd.Tree], val isRootImp for { renamed <- reverseMapping.keys denot <- pre.member(reverseMapping(renamed)).altsWith(_ is Implicit) - } yield TermRef.withSig(pre, renamed, denot.signature).withDenot(denot) + } yield TermRef.withSig(pre, renamed, denot.signature, denot) } override def toString = { diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala index 99c036fe8..3ddd3980b 100644 --- a/src/dotty/tools/dotc/typer/Namer.scala +++ b/src/dotty/tools/dotc/typer/Namer.scala @@ -166,8 +166,9 @@ class Namer { typer: Typer => adjustIfModule(new Completer(tree) withDecls newScope, tree), privateWithinClass(tree.mods), tree.pos, ctx.source.file)) case tree: MemberDef => + val deferred = if (lacksDefinition(tree)) Deferred else EmptyFlags record(ctx.newSymbol( - ctx.owner, tree.name.encode, tree.mods.flags, + ctx.owner, tree.name.encode, tree.mods.flags | deferred, adjustIfModule(new Completer(tree), tree), privateWithinClass(tree.mods), tree.pos)) case tree: Import => @@ -408,6 +409,8 @@ class Namer { typer: Typer => tp & itpe } } + // println(s"final inherited for $sym: ${inherited.toString}") !!! + // println(s"owner = ${sym.owner}, decls = ${sym.owner.info.decls.show}") def rhsType = adapt(typedAheadExpr(mdef.rhs), WildcardType).tpe.widen def lhsType = fullyDefinedType(rhsType, "right-hand side", mdef.pos) inherited orElse lhsType |