diff options
author | Martin Odersky <odersky@gmail.com> | 2007-08-27 14:15:03 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2007-08-27 14:15:03 +0000 |
commit | 44c08fe2e46779d465fd231726b7ee01d27a8c56 (patch) | |
tree | a1f513528b379250a4957bfb47ebc1c41773126a /src | |
parent | 6d8a7e73764bfeaeec795e9d4281ca5a87569791 (diff) | |
download | scala-44c08fe2e46779d465fd231726b7ee01d27a8c56.tar.gz scala-44c08fe2e46779d465fd231726b7ee01d27a8c56.tar.bz2 scala-44c08fe2e46779d465fd231726b7ee01d27a8c56.zip |
fixed bug1292
Diffstat (limited to 'src')
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/Namers.scala | 20 | ||||
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 6 |
2 files changed, 15 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index e82252c2ee..9138b2d412 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -425,7 +425,7 @@ trait Namers { self: Analyzer => } } - private def widenIfNotFinal(sym: Symbol, tpe: Type): Type = { + private def widenIfNotFinal(sym: Symbol, tpe: Type, pt: Type): Type = { val getter = if (sym.isValue && sym.owner.isClass && (sym hasFlag PRIVATE)) sym.getter(sym.owner) @@ -440,10 +440,12 @@ trait Namers { self: Analyzer => case _ => false } - if (sym.isVariable || - sym.isMethod && !(sym hasFlag ACCESSOR) || - isHidden(tpe)) tpe.widen - else if (!(sym hasFlag FINAL)) tpe.deconst + val tpe1 = tpe.deconst + val tpe2 = tpe1.widen + if ((sym.isVariable || sym.isMethod && !(sym hasFlag ACCESSOR))) + if (tpe2 <:< pt) tpe2 else tpe1 + else if (isHidden(tpe)) tpe2 + else if (!(sym hasFlag FINAL)) tpe1 else tpe } @@ -621,7 +623,7 @@ trait Namers { self: Analyzer => thisMethodType( if (tpt.isEmpty) { val pt = resultPt.substSym(tparamSyms, tparams map (_.symbol)) - tpt.tpe = widenIfNotFinal(meth, typer.computeType(rhs, pt)) + tpt.tpe = widenIfNotFinal(meth, typer.computeType(rhs, pt), pt) tpt.tpe } else typer.typedType(tpt).tpe) } @@ -730,8 +732,10 @@ trait Namers { self: Analyzer => context.error(tpt.pos, "missing parameter type"); ErrorType } else { - tpt.tpe = widenIfNotFinal(sym, - newTyper(typer1.context.make(vdef, sym)).computeType(rhs, WildcardType)) + tpt.tpe = widenIfNotFinal( + sym, + newTyper(typer1.context.make(vdef, sym)).computeType(rhs, WildcardType), + WildcardType) tpt.tpe } } else typer1.typedType(tpt).tpe diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 9fd430187e..ef5d092fe4 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -129,8 +129,7 @@ abstract class RefChecks extends InfoTransform { def overrideTypeError() { if (other.tpe != ErrorType && member.tpe != ErrorType) { - overrideError("has incompatible type "+analyzer.underlying(member).tpe.normalize); - explainTypes(member.tpe, other.tpe); + overrideError("has incompatible type "+analyzer.underlying(member).tpe.normalize) } } @@ -229,7 +228,8 @@ abstract class RefChecks extends InfoTransform { } } else if (other.isTerm) { if (!overridesType(self.memberInfo(member), self.memberInfo(other))) { // 8 - overrideTypeError(); + overrideTypeError() + explainTypes(self.memberInfo(member), self.memberInfo(other)) } } } |