Proposed fix for #2144 plus test case.

git-svn-id: http://lampsvn.epfl.ch/svn-repos/scala/scala/trunk@19399 5e8d7ff9-d8ef-0310-90f0-a4852d11357a
This commit is contained in:
extempore 2009-11-04 20:12:41 +00:00
parent 6205cc62a6
commit b43d013c52
3 changed files with 14 additions and 2 deletions

View File

@ -1700,8 +1700,13 @@ trait Typers { self: Analyzer =>
computeParamAliases(meth.owner, vparamss1, rhs1)
if (tpt1.tpe.typeSymbol != NothingClass && !context.returnsSeen) rhs1 = checkDead(rhs1)
if (meth.owner.isRefinementClass && meth.allOverriddenSymbols.isEmpty)
for (vparams <- ddef.vparamss; vparam <- vparams)
// If only refinement owned methods are checked, invalid code can result; see ticket #2144.
def requiresStructuralCheck = meth.allOverriddenSymbols.isEmpty && (
meth.owner.isRefinementClass ||
(!meth.isConstructor && !meth.isSetter && meth.owner.isAnonymousClass)
)
if (requiresStructuralCheck)
for (vparam <- ddef.vparamss.flatten)
checkStructuralCondition(meth.owner, vparam)
if (phase.id <= currentRun.typerPhase.id && meth.owner.isClass &&

View File

@ -0,0 +1,4 @@
bug2144.scala:2: error: Parameter type in structural refinement may not refer to abstract type defined outside that same refinement
def foo[A](a: A) = new { def bar(x: A): A = x }
^
one error found

View File

@ -0,0 +1,3 @@
object Test {
def foo[A](a: A) = new { def bar(x: A): A = x }
}