Skip to content
Permalink
Browse files

Widen types in names/defaults transformations.

We were getting away with this somehow, but the types are wrong after
typer and that sort of thing is noticed by more people now. I took the
opportunity to add our first -Ycheck:all test, which is at least as much
about helping -Ycheck:all remain in good working order as it is about
this test.
  • Loading branch information
paulp committed May 23, 2012
1 parent c691104 commit f026bbb2ee1d1f9bed8c3a401833bb535b856f6b
@@ -260,19 +260,18 @@ trait NamesDefaults { self: Analyzer =>
def argValDefs(args: List[Tree], paramTypes: List[Type], blockTyper: Typer): List[ValDef] = {
val context = blockTyper.context
val symPs = map2(args, paramTypes)((arg, tpe) => {
val byName = isByNameParamType(tpe)
val (argTpe, repeated) =
if (isScalaRepeatedParamType(tpe)) arg match {
case Typed(expr, Ident(tpnme.WILDCARD_STAR)) =>
(expr.tpe, true)
case _ =>
(seqType(arg.tpe), true)
} else (arg.tpe, false)
val s = context.owner.newValue(unit.freshTermName("x$"), arg.pos)
val valType = if (byName) functionType(List(), argTpe)
else if (repeated) argTpe
else argTpe
s.setInfo(valType)
val byName = isByNameParamType(tpe)
val repeated = isScalaRepeatedParamType(tpe)
val argTpe = (
if (repeated) arg match {
case Typed(expr, Ident(tpnme.WILDCARD_STAR)) => expr.tpe
case _ => seqType(arg.tpe)
}
else arg.tpe
).widen // have to widen or types inferred from literal defaults will be singletons
val s = context.owner.newValue(unit.freshTermName("x$"), arg.pos) setInfo (
if (byName) functionType(Nil, argTpe) else argTpe
)
(context.scope.enter(s), byName, repeated)
})
map2(symPs, args) {
@@ -0,0 +1 @@
-Ycheck:all
@@ -0,0 +1,13 @@
// /scala/trac/z1730/a.scala
// Wed May 23 07:41:25 PDT 2012

class X[R] {
def xx(value: => R, addTweak: Boolean = true) = 0
}

class Boo {
implicit def toX[R](v: R) : X[R] = null
def goo2 {
3.xx(34)
}
}

1 comment on commit f026bbb

@lrytz

This comment has been minimized.

Copy link
Member

@lrytz lrytz commented on f026bbb May 24, 2012

thanks for also sweeping around the house. fixes SI-5826.

Please sign in to comment.
You can’t perform that action at this time.