diff options
author | paltherr <paltherr@epfl.ch> | 2004-03-11 13:36:37 +0000 |
---|---|---|
committer | paltherr <paltherr@epfl.ch> | 2004-03-11 13:36:37 +0000 |
commit | 26d14cf7cf254f6d593f9f09e7124628a90ba725 (patch) | |
tree | 94a13face9d9883f5f78587aabfec3af915d3fc0 | |
parent | 0aa10646c74aa9e0c4c872006ed33e9305d9f4d7 (diff) | |
download | scala-26d14cf7cf254f6d593f9f09e7124628a90ba725.tar.gz scala-26d14cf7cf254f6d593f9f09e7124628a90ba725.tar.bz2 scala-26d14cf7cf254f6d593f9f09e7124628a90ba725.zip |
- Added doubledefs.scala
-rw-r--r-- | config/list/test-neg.lst | 1 | ||||
-rw-r--r-- | test/files/neg/doubledefs.check | 70 | ||||
-rw-r--r-- | test/files/neg/doubledefs.scala | 119 |
3 files changed, 190 insertions, 0 deletions
diff --git a/config/list/test-neg.lst b/config/list/test-neg.lst index 39502d0723..4a4a376e7b 100644 --- a/config/list/test-neg.lst +++ b/config/list/test-neg.lst @@ -24,6 +24,7 @@ neg/bug74.scala neg/bug75.scala neg/constrparams.scala neg/cyclic.scala +neg/doubledefs.scala neg/imports.scala neg/matthias2.scala neg/michel2.scala diff --git a/test/files/neg/doubledefs.check b/test/files/neg/doubledefs.check new file mode 100644 index 0000000000..e9d86735cc --- /dev/null +++ b/test/files/neg/doubledefs.check @@ -0,0 +1,70 @@ +doubledefs.scala:13: object tic has the same name as existing package tic +object tic { def fun = 0; } + ^ +doubledefs.scala:24: case class tac has the same name as existing package tac +case class tac { def fun = 0; } + ^ +doubledefs.scala:45: package mic has the same name as existing object mic +package mic { object module; } + ^ +doubledefs.scala:51: package mac has the same name as existing case class mac +package mac { object module; } + ^ +doubledefs.scala:64: object bic is compiled twice +object bic { def fun2 = 0; } + ^ +doubledefs.scala:70: value bac is compiled twice +case class bac { def fun2 = 0; } + ^ +doubledefs.scala:83: object cic is compiled twice +object cic { def fun2 = 0; } + ^ +doubledefs.scala:89: value cac is compiled twice +case class cac { def fun2 = 0; } + ^ +doubledefs.scala:96: class coc is compiled twice +class coc { def fun2 = 0; } + ^ +doubledefs.scala:109: class dac is compiled twice +case class dac { def fun2 = 0; } + ^ +doubledefs.scala:115: class doc is compiled twice +class doc { def fun2 = 0; } + ^ +doubledefs.scala:18: value fun is not a member of tic +object Testtic { tic.module1; tic.module2; tic.fun; } + ^ +doubledefs.scala:29: package tac of type tac.type cannot be applied to () +object Testtac { tac.module1; tac.module2; tac().fun; (new tac).fun; } + ^ +doubledefs.scala:47: value module is not a member of mic +object Testmic { mic.module; mic.fun; } + ^ +doubledefs.scala:53: value module is not a member of () => mac +object Testmac { mac.module; mac().fun; (new mac).fun; } + ^ +doubledefs.scala:66: value fun1 is not a member of bic +object Testbic { bic.fun1; bic.fun2; } + ^ +doubledefs.scala:72: value fun1 is not a member of () => bac +object Testbac { bac.fun1; bac().fun2; (new bac).fun2; } + ^ +doubledefs.scala:85: object cic of type cic.type cannot be applied to () +object Testcic { cic().fun1; (new cic).fun1; cic.fun2; } + ^ +doubledefs.scala:92: value fun1 is not a member of cac +object Testcac { cac().fun1; (new cac).fun1; cac().fun2; (new cac).fun2; } + ^ +doubledefs.scala:92: value fun1 is not a member of cac +object Testcac { cac().fun1; (new cac).fun1; cac().fun2; (new cac).fun2; } + ^ +doubledefs.scala:98: value fun1 is not a member of coc +object Testcoc { coc().fun1; (new coc).fun1; (new coc).fun2; } + ^ +doubledefs.scala:111: value fun1 is not a member of dac +object Testdac { (new dac).fun1; dac().fun2; (new dac).fun2; } + ^ +doubledefs.scala:117: value fun1 is not a member of doc +object Testdoc { (new doc).fun1; (new doc).fun2; } + ^ +23 errors found diff --git a/test/files/neg/doubledefs.scala b/test/files/neg/doubledefs.scala new file mode 100644 index 0000000000..7c4a3d64d8 --- /dev/null +++ b/test/files/neg/doubledefs.scala @@ -0,0 +1,119 @@ +//############################################################################ +// Double Definitions +//############################################################################ +// $Id$ + +//############################################################################ +// Packages followed by objects/classes with same name + +package tic { class Test1; } +package tic { object module1; } +package tic { class Test2; } +// error: object tic would hide package tic +object tic { def fun = 0; } +package tic { class Test3; } +package tic { object module2; } +package tic { class Test4; } +// error: tic.fun does not exist +object Testtic { tic.module1; tic.module2; tic.fun; } + +package tac { class Test1; } +package tac { object module1; } +package tac { class Test2; } +// error: case class tac (its factory method) would hide package tac +case class tac { def fun = 0; } +package tac { class Test3; } +package tac { object module2; } +package tac { class Test4; } +// error: tac().fun does not exits +object Testtac { tac.module1; tac.module2; tac().fun; (new tac).fun; } + +package toc { class Test1; } +package toc { object module1; } +package toc { class Test2; } +class toc { def fun = 0; } +package toc { class Test3; } +package toc { object module2; } +package toc { class Test4; } +object Testtoc { toc.module1; toc.module2; (new toc).fun; } + +//############################################################################ +// Objects/Classes followed by packages with same name + +object mic { def fun = 0; } +// error: package mic would hide object mic +package mic { object module; } +// error: mic.module does not exist +object Testmic { mic.module; mic.fun; } + +case class mac { def fun = 0; } +// error: package mac would hide case class mac (its factory method) +package mac { object module; } +// error: mac.module does not exist +object Testmac { mac.module; mac().fun; (new mac).fun; } + +class moc { def fun = 0; } +package moc { object module; } +object Testmoc { moc.module; (new moc).fun; } + +//############################################################################ +// Objects followed by Objects/Classes with same name + +object bic { def fun1 = 0; } +// error: object bic redefines object bic +object bic { def fun2 = 0; } +// error: bic.fun1 does not exist +object Testbic { bic.fun1; bic.fun2; } + +object bac { def fun1 = 0; } +// error: case class bac (its factory method) replaces object bac +case class bac { def fun2 = 0; } +// error: bac.fun1 does not exist +object Testbac { bac.fun1; bac().fun2; (new bac).fun2; } + +object boc { def fun1 = 0; } +class boc { def fun2 = 0; } +object Testboc { boc.fun1; (new boc).fun2; } + +//############################################################################ +// Case classes followed by Objects/Classes with same name + +case class cic { def fun1 = 0; } +// error: object cic replaces case class cic (its factory method) +object cic { def fun2 = 0; } +// error: cic().fun1 does not exist +object Testcic { cic().fun1; (new cic).fun1; cic.fun2; } + +case class cac { def fun1 = 0; } +// error: case class cac redefines case class cac +case class cac { def fun2 = 0; } +// error: cac().fun1 does not exist +// error: (new cac).fun1 does not exist +object Testcac { cac().fun1; (new cac).fun1; cac().fun2; (new cac).fun2; } + +case class coc { def fun1 = 0; } +// error: class coc redefines case class coc +class coc { def fun2 = 0; } +// error: (new coc).fun1 does not exist +object Testcoc { coc().fun1; (new coc).fun1; (new coc).fun2; } + +//############################################################################ +// Classes followed by Objects/Classes with same name + +class dic { def fun1 = 0; } +object dic { def fun2 = 0; } +object Testdic { (new dic).fun1; dic.fun2; } + +class dac { def fun1 = 0; } +// error: case class dac redefines class dac +case class dac { def fun2 = 0; } +// error: (new dac).fun1 does not exist +object Testdac { (new dac).fun1; dac().fun2; (new dac).fun2; } + +class doc { def fun1 = 0; } +// error: class doc redefines class doc +class doc { def fun2 = 0; } +// error: (new doc).fun1 does not exist +object Testdoc { (new doc).fun1; (new doc).fun2; } + +//############################################################################ |