| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
| |
Fixed documentation to state that addBinding will not replace a `value` that is equal (according to ==).
|
|\
| |
| | |
Correct collections variable definitions to avoid many scaladoc warnings.
|
| | |
|
|\ \
| | |
| | | |
SI-7596 Curtail overloaded symbols during unpickling
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In code like:
object O { val x = A; def x(a: Any) = ... }
object P extends O.x.A
The unpickler was using an overloaded symbol for `x` in the
parent type of `P`. This led to compilation failures under
separate compilation.
The code that leads to this is in `Unpicklers`:
def fromName(name: Name) = name.toTermName match {
case nme.ROOT => loadingMirror.RootClass
case nme.ROOTPKG => loadingMirror.RootPackage
case _ => adjust(owner.info.decl(name))
}
This commit filters the overloaded symbol based its stability
unpickling a singleton type. That seemed a slightly safer place
than in `fromName`.
|
|\ \ \
| | | |
| | | | |
Fix one typo in the scaladoc of Inliners
|
| | | |
| | | |
| | | |
| | | | |
The Scaladoc of `Inliners` contained one tiny typo for the word "accessibility".
This PR only fixes this typo.
|
|\ \ \ \
| |/ / /
|/| | | |
SI-8597 Improved pattern unchecked warnings
|
| | | |
| | | |
| | | |
| | | | |
Cherry picking some of the previous commit message.
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The spec says that `case _: List[Int]` should be always issue
an unchecked warning:
> Types which are not of one of the forms described above are
> also accepted as type patterns. However, such type patterns
> will be translated to their erasure (§3.7). The Scala compiler
> will issue an “unchecked” warning for these patterns to flag
> the possible loss of type-safety.
But the implementation goes a little further to omit warnings
based on the static type of the scrutinee. As a trivial example:
def foo(s: Seq[Int]) = s match { case _: List[Int] => }
need not issue this warning.
These discriminating unchecked warnings are domain of
`CheckabilityChecker`.
Let's deconstruct the reported bug:
def nowarn[T] = (null: Any) match { case _: Some[T] => }
We used to determine that if the first case matched, the scrutinee
type would be `Some[Any]` (`Some` is covariant). If this statically
matches `Some[T]` in a pattern context, we don't need to issue an
unchecked warning. But, our blanket use of `existentialAbstraction`
in `matchesPattern` loosened the pattern type to `Some[Any]`, and
the scrutinee type was deemed compatible.
I've added a new method, `scrutConformsToPatternType` which replaces
pattern type variables by wildcards, but leaves other abstract
types intact in the pattern type. We have to use this inside
`CheckabilityChecker` only. If we were to make `matchesPattern`
stricter in the same way, tests like `pos/t2486.scala` would fail.
I have introduced a new symbol test to (try to) identify pattern
type variables introduced by `typedBind`. Its not pretty, and it
might be cleaner to reserve a new flag for these.
I've also included a test variation exercising with nested matches.
The pattern type of the inner case can't, syntactically, refer to the
pattern type variable of the enclosing case. If it could, we would
have to be more selective in our wildcarding in `ptMatchesPatternType`
by restricting ourselves to type variables associated with the closest
enclosing `CaseDef`.
As some further validation of the correctness of this patch,
four stray warnings have been teased out of
neg/unchecked-abstract.scala
I also had to changes `typeArgsInTopLevelType` to extract the type
arguments of `Array[T]` if `T` is an abstract type. This avoids the
"Checkability checker says 'Uncheckable', but uncheckable type
cannot be found" warning and consequent overly lenient analysis.
Without this change, the warning was suppressed for:
def warnArray[T] = (null: Any) match { case _: Array[T] => }
|
|\ \ \ \
| | | | |
| | | | | |
SI-8253 Fix incorrect parsing of <elem xmlns={f("a")}/>
|
| |/ / /
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
The spliced application was placed in the `attrMap` in
`SymbolicXMLBuilder` and later incorrectly matched by a pattern
intended only to match:
xml.Text(s)
That attribute value is generated by parsing:
<elem xmlns='a'/>
So the net effect was that the two fragments of XML were identical!
This commit sharpens up the match to really look for a syntactic
`_root_.scala.xml.Text("...")`.
The test just prints the parse trees of a variety of cases, as we
we should not test the modularized XML library in scala/scala.
|
|\ \ \ \
| | | | |
| | | | | |
SI-7444 docs: null Executor allowed in ExecutionContext factories
|
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Update the ScalaDoc for the factory methods for `ExecutionContext`
which allow a `null` `Executor`/`ExecutorService`.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-5639 Fix spurious discarding of implicit import
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
To be conservative, I've predicated this fix in `-Xsource:2.12`.
This is done in separate commit to show that the previous fix
passes the test suite, rather than just tests with `-Xsource:2.12`.
|
| | |/ / /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
In Scala fa0cdc7b (just before 2.9.0), a regression in implicit
search, SI-2866, was discovered by Lift and fixed. The nature of
the regression was that an in-scope, non-implicit symbol failed to
shadow an eponymous implicit import.
The fix for this introduced `isQualifyingImplicit` which discards
in-scope implicits when the current `Context`'s scope contains
a name-clashing entry.
Incidentally, this proved to be a shallow solution, and we later
improved shadowing detection in SI-4270 / 9129cfe9. That picked
up cases where a locally defined symbol in an intervening scope
shadowed an implicit.
This commit includes the test case from the comments of SI-2866.
Part of it is tested as a neg test (to test reporting of ambiguities),
and the rest is tested in a run test (to test which implicits are
picked.)
However, in the test case of SI-5639, we see that the scope lookup
performend by `isQualifyingImplicit` is fooled by a "ghost" module
symbol. The apparition I'm referring to is entered when
`initializeFromClassPath` / `enterClassAndModule` encounters
a class file named 'Baz.class', and speculatively enters _both_ a
class and module symbol. AFAIK, this is done to defer parsing the
class file to determine what inside. If it happens to be a Java
compiled class, the module symbol is needed to house the static
members.
This commit adds a condition that `Symbol#exists` which shines a torch
(forces the info) in the direction of the ghost module symbol. In our
test, this causes it to vanish, as we only need a class symbol for
the Scala defined `class Baz`.
The existing `pos` test for this actually did not exercise the bug,
separate compilation is required. It was originally checked in to
`pending` with this error, and then later moved to `pos` when someone
noticed it was not failing.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-6502 Reenables loading jars into the running REPL (regression in 2.10)
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
- Moves mergeUrlsIntoClassPath from Global into ClassPath
- Revises and documents AbstractFile.getURL
|
| | | | | | |
|
| | | | | | |
|
| | | | | | |
|
| | | | | | |
|
| | | | | | |
|
| | |_|/ /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Fixes SI-6502, reenables loading jars into the running REPL
(regression in 2.10). This PR allows adding a jar to the compile
and runtime classpaths without resetting the REPL state (crucial
for Spark SPARK-3257).
This follows the lead taken by @som-snytt in PR #3986, which
differentiates two jar-loading behaviors (muddled by cp):
- adding jars and replaying REPL expressions (using replay)
- adding jars without resetting the REPL (deprecated cp,
introduced require) This PR implements require (left
unimplemented in #3986)
This PR is a simplification of a similar approach taken by
@gkossakowski in #3884. In this attempt, we check first to make
sure that a jar is only added if it only contains new
classes/traits/objects, otherwise we emit an error. This differs
from the old invalidation approach which also tracked deleted
classpath entries.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8835 Iterator tests can be junit
|
| | |_|/ /
| |/| | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
Without loss of generality or convenience, but helps
reduce the number of files in test/files and may reduce
compile times for test suite.
This commit includes the fix from #3963 and an extra
test of that fix that ensures the stack doesn't grow
on chained drops.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8932 Fix dropRight/takeRight implementations
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
I looked up at all the overrides of `IterableLike#takeRight` and
`IterableLike#dropRight` and replaced usages of its argument `n` with
`math.max(n, 0)` every time it was being used in an index subtraction.
Fixes [SI-8932](https://issues.scala-lang.org/browse/SI-8932).
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-8449 Fix spurious error with Java raw type over a Scala class
|
| | |_|_|/ /
| |/| | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
When the Scala typechecker typechecks signatures in Java sources,
it must enable use of a type constructor without applied type
arguments (a raw type).
However, the check in `adaptType::properTypeRequired` was too
restricive: it only allows raw types given a) we are typechecking a
Java source file and b) the type constructor itself is Java defined.
The second check does not make sense; it is perfectly legal to define
a Java raw type for over a Scala defined type constructor. This commit
removes it.
The bug was noticed in the Scaladoc context, as it explores the
signatures of all Java sources so it can document them. But the
enclosed test demonstrates the underlying bug under normal
compilation.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-8534 Avoid crash in erroneous SelectFromTypeTree
|
| |/ / / / /
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
PR #2374 changed the behaviour of `typedSingletonTypeTree` in the
presence of an error typed reference tree. It incorrectly
returns the reference tree in case on an error. However, this is
a term tree, which is an inconsistent result with the input type
tree. Consequently, a `typedSelectInternal` later fails when
using this as the qualifier of a `SelectFromTypeTree`.
Both test cases enclosed show this symptom.
This commit:
- Returns `tree` rather than `refTyped` when `refTyped` is
error typed or when it isn't suitable as a stable prefix.
- Avoids issuing a cascading "not a stable prefix" error if the
`refTyped` is error typed.
- Adds an extra layer of defense in `typedSelectFromTypeTree`
to bail out quickly if the qualifier is error typed.
The last measure is not necessary to fix this bug.
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-8967 Only add JARs and dirs from $SCALA_HOME/lib to classpath
|
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | |
| | | | | | | |
That's all we ship in that directory, but it seems that some
JVMs freak out with a core dump if something else ends up
in that directory and we add it to the boot classpath.
Testing on unix:
% rm ./build/pack/bin.complete; ant
% touch /Users/jason/code/scala/build/pack/lib/foo.txt
% mkdir /Users/jason/code/scala/build/pack/lib/dir
% bash -x ./build/pack/bin/scala -version
...
/Library/Java/JavaVirtualMachines/jdk1.8.0_20.jdk/Contents/Home/bin/java -Xmx256M -Xms32M -Xbootclasspath/a:/Users/jason/code/scala/build/pack/lib/dir:/Users/jason/code/scala/build/pack/lib/jline.jar:/Users/jason/code/scala/build/pack/lib/scala-actors.jar:/Users/jason/code/scala/build/pack/lib/scala-compiler.jar:/Users/jason/code/scala/build/pack/lib/scala-continuations-library_2.11-1.0.2.jar:/Users/jason/code/scala/build/pack/lib/scala-continuations-plugin_2.11.2-1.0.2.jar:/Users/jason/code/scala/build/pack/lib/scala-library.jar:/Users/jason/code/scala/build/pack/lib/scala-parser-combinators_2.11-1.0.2.jar:/Users/jason/code/scala/build/pack/lib/scala-partest-extras.jar:/Users/jason/code/scala/build/pack/lib/scala-partest-javaagent.jar:/Users/jason/code/scala/build/pack/lib/scala-reflect.jar:/Users/jason/code/scala/build/pack/lib/scala-swing_2.11-1.0.1.jar:/Users/jason/code/scala/build/pack/lib/scala-xml_2.11-1.0.2.jar:/Users/jason/code/scala/build/pack/lib/scalap.jar -classpath '""' -Dscala.home=/Users/jason/code/scala/build/pack -Dscala.usejavacp=true -Denv.emacs= scala.tools.nsc.MainGenericRunner -version
The boot classpath contains `build/pack/lib/dir` but not `foo.txt`.
I will seek a Windows test of the same during PR review.
|
| | | | | | | |
|
| |_|_|/ / /
|/| | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
They disappeared in dc1cd96 when `scala.tools.nsc.doc.DocParser` lost
its `override def forScaladoc = true`, which used to trigger whether to
parse `DocDef` nodes. This was deprecated in favor of a custom global
when scaladoc was modularized out (#2226), but `DocParser` didn't get it
since it didn't override `forScaladoc` anymore...
I added back `forScaladoc` in `DocParser` for consistency with
`ScaladocGlobal`, although it doesn't do anything anymore.
|
|\ \ \ \ \ \
| |_|_|/ / /
|/| | | | | |
SI-8835 Fix implementation of Iterator drop to remove quadratic behavior
|
| | |_|_|/
| |/| | | |
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-6856 Fix incorrect EBNF in comment in Parsers
|
| | |/ / /
| |/| | |
| | | | |
| | | | | |
'&' isn't a prefix operator, perhaps to the chagrin of the C crowd.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8966 Allow use of jvm-1.8 via the Ant scalac task
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | |
| | | | | |
This option has been allowed by the command line compiler since
ee706b873a28.
This commit allows use of this via Ant.
Note: we still don't exploit the features of classfile version 52,
but watch this space as we roll out method handle based closures
soon!
|
|\ \ \ \ \
| | | | | |
| | | | | | |
SI-8965 Account for corner case in "unrelated types" warning
|
| |/ / / /
| | | | |
| | | | |
| | | | |
| | | | | |
It's okay for the two types to LUB to something above `Object`
if they both individially were its supertype.
|
|\ \ \ \ \
| | | | | |
| | | | | | |
[sammy] eta-expansion, overloading, existentials
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Generate correct trees to refer to repeated params using `gen.paramToArg`.
Based on retronym's review feedback.
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Don't naively derive types for the single method's signature
from the provided function's type, as it may be a subtype
of the method's MethodType.
Instead, once the sam class type is fully defined, determine
the sam's info as seen from the class's type, and use those
to generate the correct override.
```
scala> Arrays.stream(Array(1, 2, 3)).map(n => 2 * n + 1).average.ifPresent(println)
5.0
scala> IntStream.range(1, 4).forEach(println)
1
2
3
```
Also, minimal error reporting
Can't figure out how to do it properly, but some reporting
is better than crashing. Right? Test case that illustrates
necessity of the clumsy stop gap `if (block exists (_.isErroneous))`
enclosed as `sammy_error_exist_no_crash`
added TODO for repeated and by-name params
|
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | |
| | | | | | |
Playing with Java 8 Streams from the repl showed
we weren't eta-expanding, nor resolving overloading for SAMs.
Also, the way Java uses wildcards to represent use-site variance
stresses type inference past its bendiness point (due to excessive existentials).
I introduce `wildcardExtrapolation` to simplify the resulting types
(without losing precision): `wildcardExtrapolation(tp) =:= tp`.
For example, the `MethodType` given by `def bla(x: (_ >: String)): (_ <: Int)`
is both a subtype and a supertype of `def bla(x: String): Int`.
Translating http://winterbe.com/posts/2014/07/31/java8-stream-tutorial-examples/
into Scala shows most of this works, though we have some more work to do (see near the end).
```
scala> import java.util.Arrays
scala> import java.util.stream.Stream
scala> import java.util.stream.IntStream
scala> val myList = Arrays.asList("a1", "a2", "b1", "c2", "c1")
myList: java.util.List[String] = [a1, a2, b1, c2, c1]
scala> myList.stream.filter(_.startsWith("c")).map(_.toUpperCase).sorted.forEach(println)
C1
C2
scala> myList.stream.filter(_.startsWith("c")).map(_.toUpperCase).sorted
res8: java.util.stream.Stream[?0] = java.util.stream.SortedOps$OfRef@133e7789
scala> Arrays.asList("a1", "a2", "a3").stream.findFirst.ifPresent(println)
a1
scala> Stream.of("a1", "a2", "a3").findFirst.ifPresent(println)
a1
scala> IntStream.range(1, 4).forEach(println)
<console>:37: error: object creation impossible, since method accept in trait IntConsumer of type (x$1: Int)Unit is not defined
(Note that Int does not match Any: class Int in package scala is a subclass of class Any in package scala, but method parameter types must match exactly.)
IntStream.range(1, 4).forEach(println)
^
scala> IntStream.range(1, 4).forEach(println(_: Int)) // TODO: can we avoid this annotation?
1
2
3
scala> Arrays.stream(Array(1, 2, 3)).map(n => 2 * n + 1).average.ifPresent(println(_: Double))
5.0
scala> Stream.of("a1", "a2", "a3").map(_.substring(1)).mapToInt(_.parseInt).max.ifPresent(println(_: Int)) // whoops!
ReplGlobal.abort: Unknown type: <error>, <error> [class scala.reflect.internal.Types$ErrorType$, class scala.reflect.internal.Types$ErrorType$] TypeRef? false
error: Unknown type: <error>, <error> [class scala.reflect.internal.Types$ErrorType$, class scala.reflect.internal.Types$ErrorType$] TypeRef? false
scala.reflect.internal.FatalError: Unknown type: <error>, <error> [class scala.reflect.internal.Types$ErrorType$, class scala.reflect.internal.Types$ErrorType$] TypeRef? false
at scala.reflect.internal.Reporting$class.abort(Reporting.scala:59)
scala> IntStream.range(1, 4).mapToObj(i => "a" + i).forEach(println)
a1
a2
a3
```
|
|\ \ \ \ \ \
| | | | | | |
| | | | | | | |
SI-8954 Make @deprecated{Overriding,Inheritance} aware of @deprecated.
|