diff options
-rw-r--r-- | src/compiler/scala/tools/nsc/ast/parser/Scanners.scala | 10 | ||||
-rw-r--r-- | test/files/neg/t5510.check | 19 | ||||
-rw-r--r-- | test/files/neg/t5510.scala | 7 | ||||
-rwxr-xr-x | tools/binary-repo-lib.sh | 53 |
4 files changed, 78 insertions, 11 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index 81d81a4fb7..ce38f034cf 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -231,6 +231,12 @@ trait Scanners extends ScannersCommon { lastOffset -= 1 } if (inStringInterpolation) fetchStringPart() else fetchToken() + if(token == ERROR) { + if (inMultiLineInterpolation) + sepRegions = sepRegions.tail.tail + else if (inStringInterpolation) + sepRegions = sepRegions.tail + } } else { this copyFrom next next.token = EMPTY @@ -328,7 +334,7 @@ trait Scanners extends ScannersCommon { putChar(ch) nextChar() getIdentRest() - if (ch == '"' && token == IDENTIFIER && settings.Xexperimental.value) + if (ch == '"' && token == IDENTIFIER) token = INTERPOLATIONID case '<' => // is XMLSTART? val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' @@ -697,7 +703,7 @@ trait Scanners extends ScannersCommon { do { putChar(ch) nextRawChar() - } while (Character.isUnicodeIdentifierPart(ch)) + } while (ch != SU && Character.isUnicodeIdentifierPart(ch)) next.token = IDENTIFIER next.name = newTermName(cbuf.toString) cbuf.clear() diff --git a/test/files/neg/t5510.check b/test/files/neg/t5510.check new file mode 100644 index 0000000000..f74e424dc4 --- /dev/null +++ b/test/files/neg/t5510.check @@ -0,0 +1,19 @@ +t5510.scala:2: error: unclosed string literal + val s1 = s"xxx + ^ +t5510.scala:3: error: unclosed string literal + val s2 = s"xxx $x + ^ +t5510.scala:4: error: unclosed string literal + val s3 = s"xxx $$ + ^ +t5510.scala:5: error: unclosed string literal + val s4 = ""s" + ^ +t5510.scala:6: error: unclosed multi-line string literal + val s5 = ""s""" $s1 $s2 s" + ^ +t5510.scala:7: error: Missing closing brace `}' assumed here +} + ^ +6 errors found diff --git a/test/files/neg/t5510.scala b/test/files/neg/t5510.scala new file mode 100644 index 0000000000..12630eb2cd --- /dev/null +++ b/test/files/neg/t5510.scala @@ -0,0 +1,7 @@ +object Test { + val s1 = s"xxx + val s2 = s"xxx $x + val s3 = s"xxx $$ + val s4 = ""s" + val s5 = ""s""" $s1 $s2 s" +} diff --git a/tools/binary-repo-lib.sh b/tools/binary-repo-lib.sh index 4c5497e803..09d0af1d50 100755 --- a/tools/binary-repo-lib.sh +++ b/tools/binary-repo-lib.sh @@ -88,12 +88,22 @@ pushJarFile() { # rm $jar } +getJarSha() { + local jar=$1 + if [[ ! -f "$jar" ]]; then + echo "" + else + shastring=$(sha1sum "$jar") + echo "${shastring:0:$(expr index "$shastring" " ")-1}" + fi +} + # Tests whether or not the .desired.sha1 hash matches a given file. # Arugment 1 - The jar file to test validity. # Returns: Empty string on failure, "OK" on success. isJarFileValid() { local jar=$1 - if [[ ! -f $jar ]]; then + if [[ ! -f "$jar" ]]; then echo "" else local jar_dir=$(dirname $jar) @@ -131,6 +141,27 @@ pushJarFiles() { fi } + +checkJarSha() { + local jar=$1 + local sha=$2 + local testsha=$(getJarSha "$jar") + if test "$sha" == "$testsha"; then + echo "OK" + fi +} + +makeCacheLocation() { + local uri=$1 + local sha=$2 + local cache_loc="$cache_dir/$uri" + local cdir=$(dirname $cache_loc) + if [[ ! -d "$cdir" ]]; then + mkdir -p "$cdir" + fi + echo "$cache_loc" +} + # Pulls a single binary artifact from a remote repository. # Argument 1 - The uri to the file that should be downloaded. # Argument 2 - SHA of the file... @@ -138,16 +169,19 @@ pushJarFiles() { pullJarFileToCache() { local uri=$1 local sha=$2 - local cache_loc=$cache_dir/$uri - local cdir=$(dirname $cache_loc) - if [[ ! -d $cdir ]]; then - mkdir -p $cdir - fi + local cache_loc="$(makeCacheLocation $uri)" # TODO - Check SHA of local cache is accurate. - if [[ ! -f $cache_loc ]]; then + if test -f "$cache_loc" && test "$(checkJarSha "$cache_loc" "$sha")" != "OK"; then + echo "Found bad cached file: $cache_loc" + rm -f "$cache_loc" + fi + if [[ ! -f "$cache_loc" ]]; then curlDownload $cache_loc ${remote_urlbase}/${uri} + if test "$(checkJarSha "$cache_loc" "$sha")" != "OK"; then + echo "Trouble downloading $uri. Please try pull-binary-libs again when your internet connection is stable." + exit 2 + fi fi - echo "$cache_loc" } # Pulls a single binary artifact from a remote repository. @@ -162,7 +196,8 @@ pullJarFile() { local version=${sha1% ?$jar_name} local remote_uri=${version}/${jar#$basedir/} echo "Resolving [${remote_uri}]" - local cached_file=$(pullJarFileToCache $remote_uri $version) + pullJarFileToCache $remote_uri $version + local cached_file=$(makeCacheLocation $remote_uri) cp $cached_file $jar } |