Skip to content

Testing Scabot #17

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/compiler/scala/tools/nsc/typechecker/Infer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ trait Infer extends Checkable {
else if (targ.typeSymbol == JavaRepeatedParamClass) targ.baseType(ArrayClass)
// this infers Foo.type instead of "object Foo" (see also widenIfNecessary)
else if (targ.typeSymbol.isModuleClass || tvar.constr.avoidWiden) targ
else targ.widen
else targ.deconst.widen
)
))
}
Expand Down Expand Up @@ -533,7 +533,7 @@ trait Infer extends Checkable {

// Then define remaining type variables from argument types.
map2(argtpes, formals) { (argtpe, formal) =>
val tp1 = argtpe.deconst.instantiateTypeParams(tparams, tvars)
val tp1 = argtpe.instantiateTypeParams(tparams, tvars)
val pt1 = formal.instantiateTypeParams(tparams, tvars)

// Note that isCompatible side-effects: subtype checks involving typevars
Expand Down Expand Up @@ -975,7 +975,7 @@ trait Infer extends Checkable {
try {
val pt = if (pt0.typeSymbol == UnitClass) WildcardType else pt0
val formals = formalTypes(mt.paramTypes, args.length)
val argtpes = tupleIfNecessary(formals, args map (x => elimAnonymousClass(x.tpe.deconst)))
val argtpes = tupleIfNecessary(formals, args map (x => elimAnonymousClass(x.tpe)))
val restpe = fn.tpe.resultType(argtpes)

val AdjustedTypeArgs.AllArgsAndUndets(okparams, okargs, allargs, leftUndet) =
Expand Down
18 changes: 12 additions & 6 deletions src/reflect/scala/reflect/internal/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2781,18 +2781,24 @@ trait Types
* See SI-5359.
*/
val bounds = tparam.info.bounds

/* We can seed the type constraint with the type parameter
* bounds as long as the types are concrete. This should lower
* the complexity of the search even if it doesn't improve
* any results.
*/
if (propagateParameterBoundsToTypeVars) {
val exclude = bounds.isEmptyBounds || (bounds exists typeIsNonClassType)
val constr =
if (propagateParameterBoundsToTypeVars) {
val exclude = bounds.isEmptyBounds || (bounds exists typeIsNonClassType)

if (exclude) new TypeConstraint
else TypeVar.trace("constraint", "For " + tparam.fullLocationString)(new TypeConstraint(bounds))
}
else new TypeConstraint
if (exclude) new TypeConstraint
else TypeVar.trace("constraint", "For " + tparam.fullLocationString)(new TypeConstraint(bounds))
}
else new TypeConstraint

if (bounds.hi.contains(SingletonClass)) constr.stopWidening()

constr
}
def untouchable(tparam: Symbol): TypeVar = createTypeVar(tparam, untouchable = true)
def apply(tparam: Symbol): TypeVar = createTypeVar(tparam, untouchable = false)
Expand Down
5 changes: 3 additions & 2 deletions src/reflect/scala/reflect/internal/tpe/TypeConstraints.scala
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ private[internal] trait TypeConstraints {
def loBounds: List[Type] = if (numlo == NoType) lobounds else numlo :: lobounds
def hiBounds: List[Type] = if (numhi == NoType) hibounds else numhi :: hibounds
def avoidWiden: Boolean = avoidWidening
def stopWidening(): Unit = avoidWidening = true

def addLoBound(tp: Type, isNumericBound: Boolean = false) {
// For some reason which is still a bit fuzzy, we must let Nothing through as
Expand All @@ -117,9 +118,9 @@ private[internal] trait TypeConstraints {
}

def checkWidening(tp: Type) {
if(tp.isStable) avoidWidening = true
if(tp.isStable) stopWidening()
else tp match {
case HasTypeMember(_, _) => avoidWidening = true
case HasTypeMember(_, _) => stopWidening()
case _ =>
}
}
Expand Down