Skip to content

Commit 6c398fa

Browse files
author
Antonio Cunei
committed
Merged revisions 24551-24564,24567 via svnmerge...
Merged revisions 24551-24564,24567 via svnmerge from https://lampsvn.epfl.ch/svn-repos/scala/scala/trunk ........ r24551 | odersky | 2011-03-23 16:31:04 +0100 (Wed, 23 Mar 2011) | 2 lines Squashing the signature bugs. The trick is that mixed in methods are declared as bridges. Review by extempore. ........ r24552 | odersky | 2011-03-23 16:33:58 +0100 (Wed, 23 Mar 2011) | 1 line Simple test case to see whether Java understands mixed in signatures. This should be extended with more cases. Review by extempore. ........ r24553 | odersky | 2011-03-23 19:32:39 +0100 (Wed, 23 Mar 2011) | 1 line Moving signature tests to pending, because they operate under wrong assumptions now that mixed in members are bridges. Review by extempore. ........ r24554 | odersky | 2011-03-23 22:44:13 +0100 (Wed, 23 Mar 2011) | 1 line Fixes scala#4298. Review by extempore. ........ r24555 | extempore | 2011-03-23 23:35:09 +0100 (Wed, 23 Mar 2011) | 2 lines Spiced up the signature test infrastructure a bunch, wrote some more tests, restored the tests in pending. No review. ........ r24556 | extempore | 2011-03-24 02:10:26 +0100 (Thu, 24 Mar 2011) | 2 lines Restoring my higher-kinded-Array signature check which martin callously blew away while fixing all our other problems. Review by odersky. ........ r24557 | extempore | 2011-03-24 03:35:22 +0100 (Thu, 24 Mar 2011) | 1 line Looks like I accidentally committed a test log, no review. ........ r24558 | extempore | 2011-03-24 06:49:53 +0100 (Thu, 24 Mar 2011) | 2 lines Discovered Range.foreach inlining was broken due to a Nothing signature appearing and confusing the loader. No review. ........ r24559 | extempore | 2011-03-24 08:04:32 +0100 (Thu, 24 Mar 2011) | 3 lines Removing empty directories the newly informative partest told me about. No review. ........ r24560 | extempore | 2011-03-24 09:46:55 +0100 (Thu, 24 Mar 2011) | 2 lines Changed App-using tests to use main() to see if that's our trouble. No review. ........ r24561 | odersky | 2011-03-24 12:15:37 +0100 (Thu, 24 Mar 2011) | 1 line Moved failing tests to pending after having diagnosed that the only problem is a difference in output between Java 1.5 and 1.6 reflection libraries. Can we moved back once that's fixed. For now, it's more important to ghet the build back. ........ r24562 | phaller | 2011-03-24 15:09:18 +0100 (Thu, 24 Mar 2011) | 1 line Deprecated unused members in scala.concurrent. Added documentation to scala.concurrent.ops and scala.concurrent.FutureTaskRunner. ........ r24563 | phaller | 2011-03-24 15:19:35 +0100 (Thu, 24 Mar 2011) | 1 line Added implicit TaskRunner parameters to scala.concurrent.ops.{par, replicate}. Review by prokopec. ........ r24564 | prokopec | 2011-03-24 16:00:41 +0100 (Thu, 24 Mar 2011) | 5 lines Added a temporary fix for scala#4351, but disabled it because the extend specialized class with nonspecialized type-parameters is used in the stdlib already. Disabling scala.parallel package, adding the currently disabled scala.concurrent package which will be implemented in some of the next releases. Review by phaller. ........ r24567 | odersky | 2011-03-24 17:32:15 +0100 (Thu, 24 Mar 2011) | 1 line Three things to make Eclipse more robust against deadlocks: (1) catch stale responses in presentation compile thread. (2) Avoid stale responses by two try-finallys in getEnteredParsed, askLoadedTyped. ........
1 parent 26643c8 commit 6c398fa

39 files changed

+625
-286
lines changed

src/compiler/scala/tools/nsc/backend/jvm/GenJVM.scala

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
549549

550550
// @M don't generate java generics sigs for (members of) implementation
551551
// classes, as they are monomorphic (TODO: ok?)
552-
private def noGenericSignature(sym: Symbol) = (
552+
private def needsGenericSignature(sym: Symbol) = !(
553553
// PP: This condition used to include sym.hasExpandedName, but this leads
554554
// to the total loss of generic information if a private member is
555555
// accessed from a closure: both the field and the accessor were generated
@@ -558,11 +558,11 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
558558
// unrelated change.
559559
sym.isSynthetic
560560
|| sym.isLiftedMethod
561+
|| sym.isBridge
561562
|| (sym.ownerChain exists (_.isImplClass))
562563
)
563564
def addGenericSignature(jmember: JMember, sym: Symbol, owner: Symbol) {
564-
if (noGenericSignature(sym)) ()
565-
else {
565+
if (needsGenericSignature(sym)) {
566566
val memberTpe = atPhase(currentRun.erasurePhase)(owner.thisType.memberInfo(sym))
567567
// println("addGenericSignature sym: " + sym.fullName + " : " + memberTpe + " sym.info: " + sym.info)
568568
// println("addGenericSignature: "+ (sym.ownerChain map (x => (x.name, x.isImplClass))))
@@ -572,34 +572,37 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
572572
* in which case we treat every signature as valid. Medium term we
573573
* should certainly write independent signature validation.
574574
*/
575-
if (SigParser.isParserAvailable && isValidSignature(sym, sig)) {
575+
if (SigParser.isParserAvailable && !isValidSignature(sym, sig)) {
576+
clasz.cunit.warning(sym.pos,
577+
"""|compiler bug: created invalid generic signature for %s in %s
578+
|signature: %s
579+
|if this is reproducible, please report bug at http://lampsvn.epfl.ch/trac/scala
580+
""".trim.stripMargin.format(sym, sym.owner.skipPackageObject.fullName, sig))
581+
return
582+
}
583+
if ((settings.check.value contains "genjvm")) {
576584
val normalizedTpe = atPhase(currentRun.erasurePhase)(erasure.prepareSigMap(memberTpe))
577585
val bytecodeTpe = owner.thisType.memberInfo(sym)
578-
if (sym.isType || (erasure.erasure(normalizedTpe) =:= bytecodeTpe)) {
579-
val index = jmember.getConstantPool.addUtf8(sig).toShort
580-
if (opt.verboseDebug)
581-
atPhase(currentRun.erasurePhase) {
582-
println("add generic sig "+sym+":"+sym.info+" ==> "+sig+" @ "+index)
583-
}
584-
val buf = ByteBuffer.allocate(2)
585-
buf putShort index
586-
addAttribute(jmember, tpnme.SignatureATTR, buf)
587-
} else {
588-
if (sym.hasFlag(Flags.MIXEDIN))
589-
()// println("suppressing signature for mixedin "+sym)
590-
else
591-
clasz.cunit.warning(sym.pos,
592-
"""|compiler bug: created generic signature for %s in %s that does not conform to its erasure
593-
|signature: %s
594-
|erasure type: %s
595-
|if this is reproducible, please report bug at http://lampsvn.epfl.ch/trac/scala
596-
""".trim.stripMargin.format(sym, sym.owner.skipPackageObject.fullName, sig, bytecodeTpe))
586+
if (!sym.isType && !sym.isConstructor && !(erasure.erasure(normalizedTpe) =:= bytecodeTpe)) {
587+
clasz.cunit.warning(sym.pos,
588+
"""|compiler bug: created generic signature for %s in %s that does not conform to its erasure
589+
|signature: %s
590+
|original type: %s
591+
|normalized type: %s
592+
|erasure type: %s
593+
|if this is reproducible, please report bug at http://lampsvn.epfl.ch/trac/scala
594+
""".trim.stripMargin.format(sym, sym.owner.skipPackageObject.fullName, sig, memberTpe, normalizedTpe, bytecodeTpe))
595+
return
596+
}
597+
}
598+
val index = jmember.getConstantPool.addUtf8(sig).toShort
599+
if (opt.verboseDebug)
600+
atPhase(currentRun.erasurePhase) {
601+
println("add generic sig "+sym+":"+sym.info+" ==> "+sig+" @ "+index)
597602
}
598-
} else clasz.cunit.warning(sym.pos,
599-
"""|compiler bug: created invalid generic signature for %s in %s
600-
|signature: %s
601-
|if this is reproducible, please report bug at http://lampsvn.epfl.ch/trac/scala
602-
""".trim.stripMargin.format(sym, sym.owner.skipPackageObject.fullName, sig))
603+
val buf = ByteBuffer.allocate(2)
604+
buf putShort index
605+
addAttribute(jmember, tpnme.SignatureATTR, buf)
603606
}
604607
}
605608
}
@@ -1858,7 +1861,7 @@ abstract class GenJVM extends SubComponent with GenJVMUtil with GenAndroid {
18581861
if (sym.isInterface) ACC_INTERFACE else 0,
18591862
if (sym.isFinal && !sym.enclClass.isInterface && !sym.isClassConstructor) ACC_FINAL else 0,
18601863
if (sym.isStaticMember) ACC_STATIC else 0,
1861-
if (sym.isBridge) ACC_BRIDGE else 0,
1864+
if (sym.isBridge || sym.hasFlag(Flags.MIXEDIN) && sym.isMethod) ACC_BRIDGE else 0,
18621865
if (sym.isClass && !sym.isInterface) ACC_SUPER else 0,
18631866
if (sym.isVarargsMethod) ACC_VARARGS else 0
18641867
)

src/compiler/scala/tools/nsc/interactive/CompilerControl.scala

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ trait CompilerControl { self: Global =>
103103
throw new FatalError("no context found for "+pos)
104104
}
105105

106+
private def postWorkItem(item: WorkItem) {
107+
scheduler.postWorkItem(item)
108+
}
109+
106110
/** Makes sure a set of compilation units is loaded and parsed.
107111
* Returns () to syncvar `response` on completions.
108112
* Afterwards a new background compiler run is started with
@@ -113,15 +117,15 @@ trait CompilerControl { self: Global =>
113117
case ri: ReloadItem if ri.sources == sources => Some(ri)
114118
case _ => None
115119
}
116-
superseeded foreach (_.response.set())
117-
scheduler postWorkItem new ReloadItem(sources, response)
120+
superseeded.foreach(_.response.set())
121+
postWorkItem(new ReloadItem(sources, response))
118122
}
119123

120124
/** Sets sync var `response` to the smallest fully attributed tree that encloses position `pos`.
121125
* Note: Unlike for most other ask... operations, the source file belonging to `pos` needs not be be loaded.
122126
*/
123127
def askTypeAt(pos: Position, response: Response[Tree]) =
124-
scheduler postWorkItem new AskTypeAtItem(pos, response)
128+
postWorkItem(new AskTypeAtItem(pos, response))
125129

126130
/** Sets sync var `response` to the fully attributed & typechecked tree contained in `source`.
127131
* @pre `source` needs to be loaded.
@@ -131,7 +135,7 @@ trait CompilerControl { self: Global =>
131135
println("ask type called")
132136
new Exception().printStackTrace()
133137
}
134-
scheduler postWorkItem new AskTypeItem(source, forceReload, response)
138+
postWorkItem(new AskTypeItem(source, forceReload, response))
135139
}
136140

137141
/** Sets sync var `response` to the position of the definition of the given link in
@@ -146,25 +150,25 @@ trait CompilerControl { self: Global =>
146150
* is unloaded, it stays that way.
147151
*/
148152
def askLinkPos(sym: Symbol, source: SourceFile, response: Response[Position]) =
149-
scheduler postWorkItem new AskLinkPosItem(sym, source, response)
153+
postWorkItem(new AskLinkPosItem(sym, source, response))
150154

151155
/** Sets sync var `response' to list of members that are visible
152156
* as members of the tree enclosing `pos`, possibly reachable by an implicit.
153157
* @pre source is loaded
154158
*/
155159
def askTypeCompletion(pos: Position, response: Response[List[Member]]) =
156-
scheduler postWorkItem new AskTypeCompletionItem(pos, response)
160+
postWorkItem(new AskTypeCompletionItem(pos, response))
157161

158162
/** Sets sync var `response' to list of members that are visible
159163
* as members of the scope enclosing `pos`.
160164
* @pre source is loaded
161165
*/
162166
def askScopeCompletion(pos: Position, response: Response[List[Member]]) =
163-
scheduler postWorkItem new AskScopeCompletionItem(pos, response)
167+
postWorkItem(new AskScopeCompletionItem(pos, response))
164168

165169
/** Asks to do unit corresponding to given source file on present and subsequent type checking passes */
166170
def askToDoFirst(source: SourceFile) =
167-
scheduler postWorkItem new AskToDoFirstItem(source)
171+
postWorkItem(new AskToDoFirstItem(source))
168172

169173
/** If source is not yet loaded, loads it, and starts a new run, otherwise
170174
* continues with current pass.
@@ -175,7 +179,7 @@ trait CompilerControl { self: Global =>
175179
* the a NoSuchUnitError is raised in the response.
176180
*/
177181
def askLoadedTyped(source: SourceFile, response: Response[Tree]) =
178-
scheduler postWorkItem new AskLoadedTypedItem(source, response)
182+
postWorkItem(new AskLoadedTypedItem(source, response))
179183

180184
/** If source if not yet loaded, get an outline view with askParseEntered.
181185
* If source is loaded, wait for it to be typechecked.
@@ -196,7 +200,7 @@ trait CompilerControl { self: Global =>
196200
* @param response The response.
197201
*/
198202
def askParsedEntered(source: SourceFile, keepLoaded: Boolean, response: Response[Tree]) =
199-
scheduler postWorkItem new AskParsedEnteredItem(source, keepLoaded, response)
203+
postWorkItem(new AskParsedEnteredItem(source, keepLoaded, response))
200204

201205
/** Cancels current compiler run and start a fresh one where everything will be re-typechecked
202206
* (but not re-loaded).
@@ -314,3 +318,5 @@ object ShutdownReq extends ControlThrowable
314318

315319
class NoSuchUnitError(file: AbstractFile) extends Exception("no unit found for file "+file)
316320

321+
class MissingResponse extends Exception("response missing")
322+

src/compiler/scala/tools/nsc/interactive/Global.scala

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,22 @@ class Global(settings: Settings, reporter: Reporter)
120120
}
121121
}
122122

123+
private def cleanAllResponses() {
124+
cleanResponses(waitLoadedTypeResponses)
125+
cleanResponses(getParsedEnteredResponses)
126+
}
127+
128+
private def checkNoOutstanding(rmap: ResponseMap): Unit =
129+
for ((_, rs) <- rmap.toList; r <- rs) {
130+
debugLog("ERROR: missing response, request will be discarded")
131+
r raise new MissingResponse
132+
}
133+
134+
def checkNoResponsesOutstanding() {
135+
checkNoOutstanding(waitLoadedTypeResponses)
136+
checkNoOutstanding(getParsedEnteredResponses)
137+
}
138+
123139
/** The compilation unit corresponding to a source file
124140
* if it does not yet exist create a new one atomically
125141
* Note: We want to remove this.
@@ -417,8 +433,7 @@ class Global(settings: Settings, reporter: Reporter)
417433
}
418434

419435
// clean out stale waiting responses
420-
cleanResponses(waitLoadedTypeResponses)
421-
cleanResponses(getParsedEnteredResponses)
436+
cleanAllResponses()
422437

423438
// wind down
424439
if (waitLoadedTypeResponses.nonEmpty || getParsedEnteredResponses.nonEmpty) {
@@ -841,8 +856,8 @@ class Global(settings: Settings, reporter: Reporter)
841856
else { debugLog("wait for later"); outOfDate = true; waitLoadedTypeResponses(source) += response }
842857
case None =>
843858
debugLog("load unit and type")
844-
reloadSources(List(source))
845-
waitLoadedTyped(source, response)
859+
try reloadSources(List(source))
860+
finally waitLoadedTyped(source, response)
846861
}
847862
}
848863

@@ -852,14 +867,13 @@ class Global(settings: Settings, reporter: Reporter)
852867
case Some(unit) =>
853868
getParsedEnteredNow(source, response)
854869
case None =>
855-
if (keepLoaded) {
856-
reloadSources(List(source))
857-
getParsedEnteredNow(source, response)
858-
} else if (outOfDate) {
870+
if (keepLoaded)
871+
try reloadSources(List(source))
872+
finally getParsedEnteredNow(source, response)
873+
else if (outOfDate)
859874
getParsedEnteredResponses(source) += response
860-
} else {
875+
else
861876
getParsedEnteredNow(source, response)
862-
}
863877
}
864878
}
865879

src/compiler/scala/tools/nsc/interactive/PresentationCompilerThread.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class PresentationCompilerThread(var compiler: Global, threadId: Int) extends Th
2020
compiler.debugLog("starting new runner thread")
2121
try {
2222
while (true) {
23+
compiler.checkNoResponsesOutstanding()
2324
compiler.log.logreplay("wait for more work", { compiler.scheduler.waitForMoreWork(); true })
2425
compiler.pollForWork(compiler.NoPosition)
2526
while (compiler.isOutOfDate) {

src/compiler/scala/tools/nsc/symtab/classfile/ClassfileParser.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ abstract class ClassfileParser {
264264
// println("Looking for: " + name + ": " + tpe + " inside: " + ownerTpe.typeSymbol + "\n\tand found: " + ownerTpe.members)
265265
}
266266
}
267-
assert(f != NoSymbol, "could not find " + name + ": " + tpe + "inside: \n" + ownerTpe.members)
267+
assert(f != NoSymbol, "could not find\n " + name + ": " + tpe + "\ninside:\n " + ownerTpe.members.mkString(", "))
268268
values(index) = f
269269
}
270270
f

0 commit comments

Comments
 (0)