Skip to content

Commit cf2ad53

Browse files
author
Antonio Cunei
committed
Merged revisions 24518-24521,24523 via svnmerge...
Merged revisions 24518-24521,24523 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r24518 | extempore | 2011-03-20 06:24:23 +0100 (Sun, 20 Mar 2011) | 2 lines Restored erasure warning for isInstanceOf tests. Closes scala#4302, no review. ........ r24519 | odersky | 2011-03-20 08:35:58 +0100 (Sun, 20 Mar 2011) | 1 line Commented scala#3928 patch. ........ r24520 | rytz | 2011-03-20 10:12:02 +0100 (Sun, 20 Mar 2011) | 1 line minor fix for -Xmax-classfile-name. no review ........ r24521 | magarcia | 2011-03-20 11:55:55 +0100 (Sun, 20 Mar 2011) | 1 line for .NET bootstrapping (more coming). review by rytz. ........ r24523 | magarcia | 2011-03-20 15:08:34 +0100 (Sun, 20 Mar 2011) | 3 lines The last checkin caused a test to time-out, but that test runs fine locally. I'm giving Jenkins another chance. Like the previous changeset, this one has to do with .NET bootstrapping. review by rytz. ........
1 parent ea94126 commit cf2ad53

File tree

10 files changed

+116
-193
lines changed

10 files changed

+116
-193
lines changed

src/compiler/scala/tools/nsc/backend/msil/GenMSIL.scala

Lines changed: 71 additions & 141 deletions
Large diffs are not rendered by default.

src/compiler/scala/tools/nsc/symtab/Definitions.scala

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -843,48 +843,6 @@ trait Definitions extends reflect.generic.StandardDefinitions {
843843
setParents(sym, anyvalparam)
844844
}
845845

846-
if (forMSIL) {
847-
val intType = IntClass.typeConstructor
848-
val intParam = List(intType)
849-
val longType = LongClass.typeConstructor
850-
val charType = CharClass.typeConstructor
851-
val unitType = UnitClass.typeConstructor
852-
val stringType = StringClass.typeConstructor
853-
val stringParam = List(stringType)
854-
855-
// additional methods of Object
856-
newMethod(ObjectClass, "clone", List(), AnyRefClass.typeConstructor)
857-
// wait in Java returns void, on .NET Wait returns boolean. by putting
858-
// `booltype` the compiler adds a `drop` after calling wait.
859-
newMethod(ObjectClass, "wait", List(), booltype)
860-
newMethod(ObjectClass, "wait", List(longType), booltype)
861-
newMethod(ObjectClass, "notify", List(), unitType)
862-
newMethod(ObjectClass, "notifyAll", List(), unitType)
863-
864-
// additional methods of String
865-
newMethod(StringClass, "length", List(), intType)
866-
newMethod(StringClass, "compareTo", stringParam, intType)
867-
newMethod(StringClass, "charAt", intParam, charType)
868-
newMethod(StringClass, "concat", stringParam, stringType)
869-
newMethod(StringClass, "indexOf", intParam, intType)
870-
newMethod(StringClass, "indexOf", List(intType, intType), intType)
871-
newMethod(StringClass, "indexOf", stringParam, intType)
872-
newMethod(StringClass, "indexOf", List(stringType, intType), intType)
873-
newMethod(StringClass, "lastIndexOf", intParam, intType)
874-
newMethod(StringClass, "lastIndexOf", List(intType, intType), intType)
875-
newMethod(StringClass, "lastIndexOf", stringParam, intType)
876-
newMethod(StringClass, "lastIndexOf", List(stringType, intType), intType)
877-
newMethod(StringClass, "toLowerCase", List(), stringType)
878-
newMethod(StringClass, "toUpperCase", List(), stringType)
879-
newMethod(StringClass, "startsWith", stringParam, booltype)
880-
newMethod(StringClass, "endsWith", stringParam, booltype)
881-
newMethod(StringClass, "substring", intParam, stringType)
882-
newMethod(StringClass, "substring", List(intType, intType), stringType)
883-
newMethod(StringClass, "trim", List(), stringType)
884-
newMethod(StringClass, "intern", List(), stringType)
885-
newMethod(StringClass, "replace", List(charType, charType), stringType)
886-
newMethod(StringClass, "toCharArray", List(), arrayType(charType))
887-
}
888846
isInitialized = true
889847
} //init
890848

src/compiler/scala/tools/nsc/symtab/NameManglers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ trait NameManglers {
3838
private final val marker = "$$$$"
3939
private final val MaxNameLength = math.min(
4040
settings.maxClassfileName.value - 6,
41-
2 * (settings.maxClassfileName.value - 6 - 2*marker.length - 32) + 6
41+
2 * (settings.maxClassfileName.value - 6 - 2*marker.length - 32)
4242
)
4343
private lazy val md5 = MessageDigest.getInstance("MD5")
4444
private def toMD5(s: String, edge: Int) = {

src/compiler/scala/tools/nsc/symtab/StdNames.scala

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
186186
val canEqual_ : NameType = "canEqual"
187187
val checkInitialized: NameType = "checkInitialized"
188188
val classOf: NameType = "classOf"
189-
val clone_ : NameType = "clone"
189+
val clone_ : NameType = sn.OClone
190190
val conforms: NameType = "conforms"
191191
val copy: NameType = "copy"
192192
val delayedInit: NameType = "delayedInit"
@@ -195,19 +195,19 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
195195
val drop: NameType = "drop"
196196
val elem: NameType = "elem"
197197
val eq: NameType = "eq"
198-
val equals_ : NameType = "equals"
198+
val equals_ : NameType = sn.OEquals
199199
val error: NameType = "error"
200200
val ex: NameType = "ex"
201201
val false_ : NameType = "false"
202202
val filter: NameType = "filter"
203-
val finalize_ : NameType = "finalize"
203+
val finalize_ : NameType = sn.OFinalize
204204
val find_ : NameType = "find"
205205
val flatMap: NameType = "flatMap"
206206
val foreach: NameType = "foreach"
207207
val genericArrayOps: NameType = "genericArrayOps"
208208
val get: NameType = "get"
209209
val hasNext: NameType = "hasNext"
210-
val hashCode_ : NameType = "hashCode"
210+
val hashCode_ : NameType = sn.OHashCode
211211
val hash_ : NameType = "hash"
212212
val head: NameType = "head"
213213
val identity: NameType = "identity"
@@ -246,7 +246,7 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
246246
val toArray: NameType = "toArray"
247247
val toList: NameType = "toList"
248248
val toSeq: NameType = "toSeq"
249-
val toString_ : NameType = "toString"
249+
val toString_ : NameType = sn.OToString
250250
val true_ : NameType = "true"
251251
val unapply: NameType = "unapply"
252252
val unapplySeq: NameType = "unapplySeq"
@@ -430,6 +430,12 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
430430
val Invoke : TermName
431431
val JavaLang : TermName
432432

433+
val OClone : String
434+
val OEquals : String
435+
val OFinalize : String
436+
val OHashCode : String
437+
val OToString : String
438+
433439
val Boxed: immutable.Map[TypeName, TypeName]
434440
}
435441

@@ -527,6 +533,12 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
527533
final val Invoke: TermName = "invoke"
528534
final val JavaLang: TermName = "java.lang"
529535

536+
final val OClone = "clone"
537+
final val OEquals = "equals"
538+
final val OFinalize = "finalize"
539+
final val OHashCode = "hashCode"
540+
final val OToString = "toString"
541+
530542
val Boxed = immutable.Map[TypeName, TypeName](
531543
tpnme.Boolean -> BoxedBoolean,
532544
tpnme.Byte -> BoxedByte,
@@ -565,9 +577,15 @@ trait StdNames extends reflect.generic.StdNames with NameManglers {
565577
final val Invoke: TermName = "Invoke"
566578
final val JavaLang: TermName = "System"
567579

580+
final val OClone = "MemberwiseClone"
581+
final val OEquals = "Equals"
582+
final val OFinalize = "Finalize"
583+
final val OHashCode = "GetHashCode"
584+
final val OToString = "ToString"
585+
568586
val Boxed = immutable.Map[TypeName, TypeName](
569587
tpnme.Boolean -> "System.Boolean",
570-
tpnme.Byte -> "System.Byte",
588+
tpnme.Byte -> "System.SByte", // a scala.Byte is signed and a System.SByte too (unlike a System.Byte)
571589
tpnme.Char -> "System.Char",
572590
tpnme.Short -> "System.Int16",
573591
tpnme.Int -> "System.Int32",

src/compiler/scala/tools/nsc/symtab/clr/CLRTypes.scala

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,20 @@ abstract class CLRTypes {
6666

6767
def isAddressOf(msym : Symbol) = addressOfViews.contains(msym)
6868

69-
def isNonEnumValuetype(clssym : Symbol) = {
70-
val msilTOpt = types.get(clssym)
69+
def isNonEnumValuetype(cls: Symbol) = {
70+
val msilTOpt = types.get(cls)
7171
val res = msilTOpt.isDefined && {
7272
val msilT = msilTOpt.get
7373
msilT.IsValueType && !msilT.IsEnum
7474
}
7575
res
7676
}
7777

78+
def isValueType(cls: Symbol): Boolean = {
79+
val opt = types.get(cls)
80+
opt.isDefined && opt.get.IsValueType
81+
}
82+
7883
def init() = try { // initialize
7984
// the MsilClasspath (nsc/util/Classpath.scala) initializes the msil-library by calling
8085
// Assembly.LoadFrom("mscorlib.dll"), so this type should be found

src/compiler/scala/tools/nsc/typechecker/Infer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1312,7 +1312,7 @@ trait Infer {
13121312
((bound contains sym) ||
13131313
sym.name == tpnme.WILDCARD || {
13141314
val e = context.scope.lookupEntry(sym.name)
1315-
(e ne null) && e.sym == sym && e.owner == context.scope
1315+
(e ne null) && e.sym == sym && !e.sym.isTypeParameterOrSkolem && e.owner == context.scope
13161316
})
13171317
tp match {
13181318
case SingleType(pre, _) =>

src/compiler/scala/tools/nsc/typechecker/Typers.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4268,6 +4268,10 @@ trait Typers extends Modes {
42684268

42694269
val restpe = result.tpe.normalize // normalize to get rid of type aliases for the following check (#1241)
42704270
if (!phase.erasedTypes && restpe.isInstanceOf[TypeRef] && !restpe.prefix.isStable && !context.unit.isJava) {
4271+
// The isJava exception if OK only because the only type constructors scalac gets
4272+
// to see are those in the signatures. These do not need a unique object as a prefix.
4273+
// The situation is different for new's and super's, but scalac does not look deep
4274+
// enough to see those. See #3938
42714275
error(tree.pos, restpe.prefix+" is not a legal prefix for a constructor")
42724276
}
42734277

test/files/neg/bug4302.check

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
bug4302.scala:2: error: abstract type T in type T is unchecked since it is eliminated by erasure
2+
def hasMatch[T](x: AnyRef) = x.isInstanceOf[T]
3+
^
4+
one error found

test/files/neg/bug4302.flags

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
-unchecked -Xfatal-warnings

test/files/neg/bug4302.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object Test {
2+
def hasMatch[T](x: AnyRef) = x.isInstanceOf[T]
3+
}

0 commit comments

Comments
 (0)