From: Jean Privat Date: Thu, 30 Jun 2016 18:15:25 +0000 (-0400) Subject: Merge remote-tracking branch 'origin/master' into init_auto X-Git-Url: http://nitlanguage.org Merge remote-tracking branch 'origin/master' into init_auto # Conflicts: # tests/sav/base_init_basic_alt3.res # tests/sav/base_init_super_call2_alt3.res # tests/sav/base_init_super_call2_alt6.res # tests/sav/error_class_glob.res # tests/sav/nitdoc_args4.res # tests/sav/nitlight_args1.res # tests/sav/nitmetrics_args1.res # tests/sav/nituml_args3.res # tests/sav/nituml_args4.res # tests/sav/test_highlight_args1.res --- 93582db8a72ed0dc8662f6fb57feda89a284ad57 diff --cc src/modelize/modelize_property.nit index 8c167c6,246e813..98f97e2 --- a/src/modelize/modelize_property.nit +++ b/src/modelize/modelize_property.nit @@@ -353,19 -339,26 +353,19 @@@ redef class ModelBuilde end end - # If we already have a basic init definition, then setup its initializers - if defined_init != null then - defined_init.initializers.add_all(initializers) + # Create a specific new autoinit constructor + do - var mprop = new MMethod(mclassdef, "autoinit", public_visibility) ++ var mprop = new MMethod(mclassdef, "autoinit", nclassdef.location, public_visibility) + mprop.is_init = true + var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location) + mpropdef.initializers.add_all(initializers) var msignature = new MSignature(mparameters, null) - defined_init.new_msignature = msignature - self.toolcontext.info("{mclassdef} extends its basic constructor signature to {defined_init}{msignature}", 3) - mclassdef.mclass.root_init = defined_init - return + mpropdef.msignature = msignature + mclassdef.auto_init = mpropdef + self.toolcontext.info("{mclassdef} gets a free auto constructor `{mpropdef}{msignature}`. {spropdefs}", 3) + #mclassdef.mclass.root_init = mpropdef + mclassdef.mclass.the_root_init_mmethod = the_root_init_mmethod end - - # Else create the local implicit basic init definition - var mprop = the_root_init_mmethod - var mpropdef = new MMethodDef(mclassdef, mprop, nclassdef.location) - mpropdef.has_supercall = true - mpropdef.initializers.add_all(initializers) - var msignature = new MSignature(mparameters, null) - mpropdef.new_msignature = msignature - mpropdef.msignature = new MSignature(new Array[MParameter], null) # always an empty real signature - self.toolcontext.info("{mclassdef} gets a free constructor for attributes {mpropdef}{msignature}", 3) - mclassdef.mclass.root_init = mpropdef end # Check the visibility of `mtype` as an element of the signature of `mpropdef`. diff --cc tests/sav/base_init_basic_alt3.res index d856b64,84d579c..f7e3b6d --- a/tests/sav/base_init_basic_alt3.res +++ b/tests/sav/base_init_basic_alt3.res @@@ -1,2 -1,2 +1,2 @@@ - alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3#D#autoinit(c=, b=) and base_init_basic_alt3#E#autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=` - alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3#D#autoinit(c=, b=) and base_init_basic_alt3#E#autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=, g=` -alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3$E$init(c=, e=) and base_init_basic_alt3$D$init(c=, b=). Use `autoinit` to order initializers. eg `autoinit c=, b=, e=` -alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3$E$init(c=, e=) and base_init_basic_alt3$D$init(c=, b=). Use `autoinit` to order initializers. eg `autoinit c=, b=, e=, g=` ++alt/base_init_basic_alt3.nit:47,7: Error: cannot generate automatic init for class F. Conflict in the order in inherited initializers base_init_basic_alt3$D$autoinit(c=, b=) and base_init_basic_alt3$E$autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=` ++alt/base_init_basic_alt3.nit:54,7: Error: cannot generate automatic init for class G. Conflict in the order in inherited initializers base_init_basic_alt3$D$autoinit(c=, b=) and base_init_basic_alt3$E$autoinit(c=, e=). Use `autoinit` to order initializers. eg `autoinit c=, e=, b=, g=` diff --cc tests/sav/nitdoc_args4.res index c1ed475,9238b51..53f4e84 --- a/tests/sav/nitdoc_args4.res +++ b/tests/sav/nitdoc_args4.res @@@ -1110,24 -1034,24 +1137,24 @@@ MModulePage rp #### test_prog__rpg__rpg.imports #### test_prog__rpg__rpg.clients - Generated 115 pages -Generated 99 pages ++Generated 118 pages list: - MPropertyPage: 77 (66.95%) - MClassPage: 20 (17.39%) - MModulePage: 8 (6.95%) - MGroupPage: 4 (3.47%) - ReadmePage: 4 (3.47%) - SearchPage: 1 (0.86%) - OverviewPage: 1 (0.86%) - Found 219 mentities - MPropertyPage: 58 (58.58%) - MClassPage: 20 (20.20%) - MModulePage: 9 (9.09%) - ReadmePage: 5 (5.05%) - MGroupPage: 5 (5.05%) - SearchPage: 1 (1.01%) - OverviewPage: 1 (1.01%) -Found 185 mentities ++ MPropertyPage: 77 (65.25%) ++ MClassPage: 20 (16.94%) ++ MModulePage: 9 (7.62%) ++ ReadmePage: 5 (4.23%) ++ MGroupPage: 5 (4.23%) ++ SearchPage: 1 (0.84%) ++ OverviewPage: 1 (0.84%) ++Found 222 mentities list: - MMethodDef: 86 (39.26%) - MMethod: 76 (34.70%) - MClassDef: 22 (10.04%) - MClass: 20 (9.13%) - MModule: 8 (3.65%) - MGroup: 4 (1.82%) - MMethodDef: 68 (36.75%) - MMethod: 57 (30.81%) - MClassDef: 22 (11.89%) - MClass: 20 (10.81%) - MModule: 9 (4.86%) - MGroup: 5 (2.70%) - MPackage: 2 (1.08%) - MVirtualTypeDef: 1 (0.54%) - MVirtualTypeProp: 1 (0.54%) ++ MMethodDef: 86 (38.73%) ++ MMethod: 76 (34.23%) ++ MClassDef: 22 (9.90%) ++ MClass: 20 (9.00%) ++ MModule: 9 (4.05%) ++ MGroup: 5 (2.25%) ++ MPackage: 2 (0.90%) + MVirtualTypeDef: 1 (0.45%) + MVirtualTypeProp: 1 (0.45%) - MPackage: 1 (0.45%) quicksearch-list.js diff --cc tests/sav/nitlight_args1.res index 4a24924,cf89e02..00f8ce6 --- a/tests/sav/nitlight_args1.res +++ b/tests/sav/nitlight_args1.res @@@ -16,52 -16,52 +16,52 @@@ import end - interface Object + interface Object end - enum Bool + enum Bool end - enum Int - fun output is intern + enum Int + fun output is intern end - class A - init do 5.output - fun run do 6.output + class A + init do 5.output + fun run do 6.output end - class B - var val: Int - init(v: Int) + class B + var val: Int - init(v: Int) ++ init(v: Int) do - 7.output - self.val = v + 7.output + self.val = v end - fun run do val.output + fun run do val.output end - class C - var val1: Int - var val2: Int = 10 + class C + var val1: Int + var val2: Int = 10 end - fun foo do 2.output - fun bar(i: Int) do i.output - fun baz: Int do return 4 + fun foo do 2.output + fun bar(i: Int) do i.output + fun baz: Int do return 4 - 1.output - foo - bar(3) - baz.output + 1.output + foo + bar(3) + baz.output - var a = new A - a.run -var a = new A ++var a = new A + a.run - var b = new B(8) - b.run -var b = new B(8) ++var b = new B(8) + b.run - var c = new C(9) - c.val1.output - c.val2.output -var c = new C(9) ++var c = new C(9) + c.val1.output + c.val2.output diff --cc tests/sav/nitmetrics_args1.res index f6ad37b,6d734f6..7e642cc --- a/tests/sav/nitmetrics_args1.res +++ b/tests/sav/nitmetrics_args1.res @@@ -868,17 -869,17 +868,17 @@@ MMethodDef locally designated (by numbe <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) list: - base_simple3#Int#output: 10 (43.47%) - base_simple3#B#val: 1 (4.34%) - base_simple3#B#val=: 1 (4.34%) - base_simple3#Object#init: 1 (4.34%) - base_simple3#C#val2: 1 (4.34%) + base_simple3$Int$output: 10 (43.47%) + base_simple3$B$val: 1 (4.34%) + base_simple3$B$val=: 1 (4.34%) + base_simple3$Object$init: 1 (4.34%) + base_simple3$C$val2: 1 (4.34%) ... - base_simple3#A#autoinit: 1 (4.34%) - base_simple3#Sys#baz: 1 (4.34%) - base_simple3#Sys#bar: 1 (4.34%) - base_simple3#Sys#foo: 1 (4.34%) - base_simple3#C#autoinit: 1 (4.34%) - base_simple3$A$init: 1 (4.34%) ++ base_simple3$A$autoinit: 1 (4.34%) + base_simple3$Sys$baz: 1 (4.34%) + base_simple3$Sys$bar: 1 (4.34%) + base_simple3$Sys$foo: 1 (4.34%) - base_simple3$C$init: 1 (4.34%) ++ base_simple3$C$autoinit: 1 (4.34%) MMethodDef possibly invoked at runtime (by number of CallSites) population: 14 minimum value: 1 @@@ -889,17 -890,17 +889,17 @@@ <=1: sub-population=13 (92.85%); cumulated value=13 (56.52%) <=16: sub-population=1 (7.14%); cumulated value=10 (43.47%) list: - base_simple3#Int#output: 10 (43.47%) - base_simple3#B#val: 1 (4.34%) - base_simple3#B#val=: 1 (4.34%) - base_simple3#Object#init: 1 (4.34%) - base_simple3#C#val2: 1 (4.34%) + base_simple3$Int$output: 10 (43.47%) + base_simple3$B$val: 1 (4.34%) + base_simple3$B$val=: 1 (4.34%) + base_simple3$Object$init: 1 (4.34%) + base_simple3$C$val2: 1 (4.34%) ... - base_simple3#A#autoinit: 1 (4.34%) - base_simple3#Sys#baz: 1 (4.34%) - base_simple3#Sys#bar: 1 (4.34%) - base_simple3#Sys#foo: 1 (4.34%) - base_simple3#C#autoinit: 1 (4.34%) - base_simple3$A$init: 1 (4.34%) ++ base_simple3$A$autoinit: 1 (4.34%) + base_simple3$Sys$baz: 1 (4.34%) + base_simple3$Sys$bar: 1 (4.34%) + base_simple3$Sys$foo: 1 (4.34%) - base_simple3$C$init: 1 (4.34%) ++ base_simple3$C$autoinit: 1 (4.34%) class_hierarchy.dot classdef_hierarchy.dot inheritance/ diff --cc tests/sav/nituml_args3.res index 338a3d9,a43ae0d..4e62b3e --- a/tests/sav/nituml_args3.res +++ b/tests/sav/nituml_args3.res @@@ -51,7 -51,7 +51,7 @@@ Float Numeric -> Float [dir=back arrowtail=open style=dashed]; Byte [ - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ autoinit()\l}" - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l}" ++ label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Byte [dir=back arrowtail=open style=dashed]; Numeric -> Byte [dir=back arrowtail=open style=dashed]; diff --cc tests/sav/nituml_args4.res index de63dda,4bd5666..c79556c --- a/tests/sav/nituml_args4.res +++ b/tests/sav/nituml_args4.res @@@ -51,7 -51,7 +51,7 @@@ Float Numeric -> Float [dir=back arrowtail=open style=dashed]; Byte [ - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ autoinit()\l}" - label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l}" ++ label = "{Byte||+ %(i: Byte): Byte\l+ \<\<(i: Int): Byte\l+ \>\>(i: Int): Byte\l+ ascii(): Char\l+ is_whitespace(): Bool\l+ autoinit()\l}" ] Discrete -> Byte [dir=back arrowtail=open style=dashed]; Numeric -> Byte [dir=back arrowtail=open style=dashed]; diff --cc tests/sav/test_highlight_args1.res index 6919258,e6ac401..8faceb9 --- a/tests/sav/test_highlight_args1.res +++ b/tests/sav/test_highlight_args1.res @@@ -40,110 -41,110 +41,110 @@@ -

base_simple3#Int#output

-
	fun output is intern
-

base_simple3#A#Object::init

-
	init do 5.output
-

base_simple3#A#run

-
	fun run do 6.output
-

base_simple3#B#_val

-
	var val: Int
-

base_simple3#B#val

-
	var val: Int
-

base_simple3#B#val=

-
	var val: Int
-

base_simple3#B#autoinit

-
	init(v: Int)
+ 

base_simple3$Int$output

+
	fun output is intern
+

base_simple3$A$Object::init

+
	init do 5.output
+

base_simple3$A$run

+
	fun run do 6.output
+

base_simple3$B$_val

+
	var val: Int
+

base_simple3$B$val

+
	var val: Int
+

base_simple3$B$val=

+
	var val: Int
-

base_simple3$B$init

-
	init(v: Int)
++

base_simple3$B$autoinit

++
	init(v: Int)
  	do
- 		7.output
- 		self.val = v
+ 		7.output
+ 		self.val = v
  	end
-

base_simple3#B#run

-
	fun run do val.output
-

base_simple3#C#_val1

-
	var val1: Int
-

base_simple3#C#val1

-
	var val1: Int
-

base_simple3#C#val1=

-
	var val1: Int
-

base_simple3#C#_val2

-
	var val2: Int = 10
-

base_simple3#C#val2

-
	var val2: Int = 10
-

base_simple3#C#val2=

-
	var val2: Int = 10
-

base_simple3#Sys#foo

-
fun foo do 2.output
-

base_simple3#Sys#bar

-
fun bar(i: Int) do i.output
-

base_simple3#Sys#baz

-
fun baz: Int do return 4
-

base_simple3#Sys#main

-
1.output
- foo
- bar(3)
- baz.output
+ 

base_simple3$B$run

+
	fun run do val.output
+

base_simple3$C$_val1

+
	var val1: Int
+

base_simple3$C$val1

+
	var val1: Int
+

base_simple3$C$val1=

+
	var val1: Int
+

base_simple3$C$_val2

+
	var val2: Int = 10
+

base_simple3$C$val2

+
	var val2: Int = 10
+

base_simple3$C$val2=

+
	var val2: Int = 10
+

base_simple3$Sys$foo

+
fun foo do 2.output
+

base_simple3$Sys$bar

+
fun bar(i: Int) do i.output
+

base_simple3$Sys$baz

+
fun baz: Int do return 4
+

base_simple3$Sys$main

+
1.output
+ foo
+ bar(3)
+ baz.output
  
- var a = new A
- a.run
 -var a = new A
++var a = new A
+ a.run
  
- var b = new B(8)
- b.run
 -var b = new B(8)
++var b = new B(8)
+ b.run
  
- var c = new C(9)
- c.val1.output
- c.val2.output
-
var c = new C(9) ++var c = new C(9) + c.val1.output + c.val2.output

AST node: AModule at base_simple3.nit:17,1--66,13

import end
  
- interface Object
+ interface Object
  end
  
- enum Bool
+ enum Bool
  end
  
- enum Int
- 	fun output is intern
+ enum Int
+ 	fun output is intern
  end
  
- class A
- 	init do 5.output
- 	fun run do 6.output
+ class A
+ 	init do 5.output
+ 	fun run do 6.output
  end
  
- class B
- 	var val: Int
- 	init(v: Int)
+ class B
+ 	var val: Int
 -	init(v: Int)
++	init(v: Int)
  	do
- 		7.output
- 		self.val = v
+ 		7.output
+ 		self.val = v
  	end
- 	fun run do val.output
+ 	fun run do val.output
  end
  
- class C
- 	var val1: Int
- 	var val2: Int = 10
+ class C
+ 	var val1: Int
+ 	var val2: Int = 10
  end
  
- fun foo do 2.output
- fun bar(i: Int) do i.output
- fun baz: Int do return 4
+ fun foo do 2.output
+ fun bar(i: Int) do i.output
+ fun baz: Int do return 4
  
- 1.output
- foo
- bar(3)
- baz.output
+ 1.output
+ foo
+ bar(3)
+ baz.output
  
- var a = new A
- a.run
 -var a = new A
++var a = new A
+ a.run
  
- var b = new B(8)
- b.run
 -var b = new B(8)
++var b = new B(8)
+ b.run
  
- var c = new C(9)
- c.val1.output
- c.val2.output
-
var c = new C(9) ++var c = new C(9) + c.val1.output + c.val2.output

AST node: ANoImport at base_simple3.nit:17,1--10

import end

AST node: APublicVisibility at base_simple3.nit:17,1

@@@ -190,92 -191,5 +191,8 @@@

AST node: TKwclass at base_simple3.nit:29,1--5

class

AST node: TKwinit at base_simple3.nit:30,2--5

-
	init
+
	init
-

AST node: TKwdo at base***TRUNCATED*** +

AST node: TKwdo at base_simple3.nit:30,7--8

+
 do
+

AST node: ACallExpr at base_simple3.nit:30,10--17

-
 5.output
-

AST node: AIntegerExpr at base_simple3.nit:30,10

-
 5
-

AST node: TInteger at base_simple3.nit:30,10

-
 5
-

AST node: AQid at base_simple3.nit:30,12--17

-
output
-

AST node: AListExprs at base_simple3.nit:30,17

-
-

AST node: AAttrPropdef at base_simple3.nit:35,2--13

-
	var val: Int
-

AST node: TKwvar at base_simple3.nit:35,2--4

-
	var
-

AST node: AType at base_simple3.nit:35,11--13

-
 Int
-

AST node: TOpar at base_simple3.nit:36,6

-
(
-

AST node: AParam at base_simple3.nit:36,7--12

-
v: Int
-

AST node: TCpar at base_simple3.nit:36,13

-
)
-

AST node: ABlockExpr at base_simple3.nit:38,3--40,4

-
		7.output
- 		self.val = v
- 	end
-

AST node: ACallAssignExpr at base_simple3.nit:39,3--14

-
		self.val = v
-

AST node: ASelfExpr at base_simple3.nit:39,3--6

-
		self
-

AST node: TKwself at base_simple3.nit:39,3--6

-
		self
-

AST node: TAssign at base_simple3.nit:39,12

-
 =
-

AST node: AVarExpr at base_simple3.nit:39,14

-
 v
-

AST node: AImplicitSelfExpr at base_simple3.nit:41,13

-
-

AST node: ATopClassdef at base_simple3.nit:49,1--19

-
fun foo do 2.output
-

AST node: AReturnExpr at base_simple3.nit:51,17--24

-
 return 4
-

AST node: TKwreturn at base_simple3.nit:51,17--22

-
 return
-

AST node: AMainClassdef at base_simple3.nit:53,1--66,13

-
1.output
- foo
- bar(3)
- baz.output
- 
- var a = new A
- a.run
- 
- var b = new B(8)
- b.run
- 
- var c = new C(9)
- c.val1.output
- c.val2.output
-

AST node: AMainMethPropdef at base_simple3.nit:53,1--66,13

-
1.output
- foo
- bar(3)
- baz.output
- 
- var a = new A
- a.run
- 
- var b = new B(8)
- b.run
- 
- var c = new C(9)
- c.val1.output
- c.val2.output
-

AST node: AParExprs at base_simple3.nit:55,4--6

-
(3)
-

AST node: AVardeclExpr at base_simple3.nit:58,1--13

-
var a = new A
-

AST node: ANewExpr at base_simple3.nit:58,9--13

-
 new A
-

AST node: TKwnew at base_simple3.nit:58,9--11

-
 new
- - - - ++
 5